package com.hpin.mlxteacher.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * 群列表bean
 * Created by Aaron on 16/2/25.
 */
public class GroupBean implements Parcelable {

    /**
     * topicList : [{"_id":"56ce6cb37e1ccb8c19244f9b","topic":"56ce6cb37e1ccb8c19244f9b","__v":0,"lastTime":1456368819678,"type":0,"history":[],"userList":[{"user":{"_id":"56c02cb00d75d9c832a534ec","phoneNum":"15311280989","imgUrl":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-12-09/2ikn3vawnd0vllir0ap01qka568tu7je_s","nickName":"lee"},"_id":"56ce6cb37e1ccb8c19244f9c","isAdmin":true},{"user":{"_id":"56c13bee99dc8715760e296f","phoneNum":"18310861283","imgUrl":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-11-27/le9cmojl0nrjxsz5xiqo6i68ke9ra0h2_s","nickName":"小丽"},"_id":"56ce6cb37e1ccb8c19244f9d","isAdmin":false},{"user":{"_id":"56bf25eb99dc8715760e2967","phoneNum":"18610915892","imgUrl":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-01-25/v65fu9khaab7pbv51g1djcyah3fwdzbv4wjlvsac2mm81ci1ue5zmkr8phah1l31_s","nickName":"冯"},"_id":"56ce6cb37e1ccb8c19244f9e","isAdmin":false}],"groupImgUrl":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-02-25/cw6zt34e07ta9biby7svbolohumh0vhcbup9racigng67nosh18229xtmgtg8z3b","groupName":"小丽、冯、lee"}]
     * code : 0
     * code_msg : 成功
     */
    public int code;
    public String code_msg;

    public List<TopicListEntity> topicList;

    public static class TopicListEntity implements Parcelable {
        public String _id;
        public String topic;
        public int __v;
        public long lastTime;
        public int type;
        public String groupImgUrl;
        public String groupName;
        public List<String> history;
        /**
         * user : {"_id":"56c02cb00d75d9c832a534ec","phoneNum":"15311280989","imgUrl":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-12-09/2ikn3vawnd0vllir0ap01qka568tu7je_s","nickName":"lee"}
         * _id : 56ce6cb37e1ccb8c19244f9c
         * isAdmin : true
         */
        
        public static class UserListEntity implements Parcelable {
            /**
             * _id : 56c02cb00d75d9c832a534ec
             * phoneNum : 15311280989
             * imgUrl : http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-12-09/2ikn3vawnd0vllir0ap01qka568tu7je_s
             * nickName : lee
             */

            public UserEntity user;
            public String _id;
            public boolean isAdmin;

            public static class UserEntity implements Parcelable {
                public String _id;
                public String phoneNum;
                public String imgUrl;
                public String nickName;

                @Override
                public int describeContents() {
                    return 0;
                }

                @Override
                public void writeToParcel(Parcel dest, int flags) {
                    dest.writeString(this._id);
                    dest.writeString(this.phoneNum);
                    dest.writeString(this.imgUrl);
                    dest.writeString(this.nickName);
                }

                public UserEntity() {
                }

                protected UserEntity(Parcel in) {
                    this._id = in.readString();
                    this.phoneNum = in.readString();
                    this.imgUrl = in.readString();
                    this.nickName = in.readString();
                }

                public static final Creator<UserEntity> CREATOR = new Creator<UserEntity>() {
                    public UserEntity createFromParcel(Parcel source) {
                        return new UserEntity(source);
                    }

                    public UserEntity[] newArray(int size) {
                        return new UserEntity[size];
                    }
                };
            }

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeParcelable(this.user, 0);
                dest.writeString(this._id);
                dest.writeByte(isAdmin ? (byte) 1 : (byte) 0);
            }

            public UserListEntity() {
            }

            protected UserListEntity(Parcel in) {
                this.user = in.readParcelable(UserEntity.class.getClassLoader());
                this._id = in.readString();
                this.isAdmin = in.readByte() != 0;
            }

            public static final Creator<UserListEntity> CREATOR = new Creator<UserListEntity>() {
                public UserListEntity createFromParcel(Parcel source) {
                    return new UserListEntity(source);
                }

                public UserListEntity[] newArray(int size) {
                    return new UserListEntity[size];
                }
            };
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this._id);
            dest.writeString(this.topic);
            dest.writeInt(this.__v);
            dest.writeLong(this.lastTime);
            dest.writeInt(this.type);
            dest.writeString(this.groupImgUrl);
            dest.writeString(this.groupName);
            dest.writeStringList(this.history);
        }

        public TopicListEntity() {
        }

        protected TopicListEntity(Parcel in) {
            this._id = in.readString();
            this.topic = in.readString();
            this.__v = in.readInt();
            this.lastTime = in.readLong();
            this.type = in.readInt();
            this.groupImgUrl = in.readString();
            this.groupName = in.readString();
            this.history = in.createStringArrayList();
        }

        public static final Creator<TopicListEntity> CREATOR = new Creator<TopicListEntity>() {
            public TopicListEntity createFromParcel(Parcel source) {
                return new TopicListEntity(source);
            }

            public TopicListEntity[] newArray(int size) {
                return new TopicListEntity[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.code);
        dest.writeString(this.code_msg);
        dest.writeTypedList(topicList);
    }

    public GroupBean() {
    }

    protected GroupBean(Parcel in) {
        this.code = in.readInt();
        this.code_msg = in.readString();
        this.topicList = in.createTypedArrayList(TopicListEntity.CREATOR);
    }

    public static final Creator<GroupBean> CREATOR = new Creator<GroupBean>() {
        public GroupBean createFromParcel(Parcel source) {
            return new GroupBean(source);
        }

        public GroupBean[] newArray(int size) {
            return new GroupBean[size];
        }
    };
}
